﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace zuoweishigefeiwu1
{
    public partial class zuoweiTools : Form
    {
        public zuoweiTools()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DirectoryInfo TheFolder = new DirectoryInfo(textBoxfolder.Text);


            //遍历文件
            foreach (FileInfo NextFile in TheFolder.GetFiles())
            {
                if (NextFile.Name.EndsWith(".txt"))
                {

                    using (StreamReader sr = new StreamReader(NextFile.FullName))
                    {

                        string str = sr.ReadToEnd();
                        sr.Close();
                        str=str.Replace(textBoxolder.Text, textBoxNewer.Text);
                        System.IO.File.WriteAllText(NextFile.FullName, str);
                    }
                }
            }


        }

    }
}

